﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Classes
{

    [DataContract]
    public class City
    {
        private String name;
        private String country;
        private List<Flight> flightList;
        private int id;
        private bool _mark;
        private int priceToGetHere; //my Distance field
        IList<City> path; //
        TimeSpan timeToGetHere;
        


        public City()
        {

        }

        public City(String name, String country) // all fields ?? :C
        {
            _mark = false;
            this.name = name;
            this.country = country;
            flightList = new List<Flight>();
            priceToGetHere = int.MaxValue;
            path = new List<City>();
            timeToGetHere = TimeSpan.MaxValue;
        }

        
       
        
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
     
        public List<Flight> Flights() //must return a List in order to be able to remove edges
        {
            return flightList;
        }
       
        public void AddFlight(City to, int noOfSeats, int id, DateTime dt, DateTime arrival, int price, string company)
        {
            Flight f = new Flight(this, to);
            f.NoOfSeats = noOfSeats;
            f.Id = id;
            f.DepartureTime = dt;
            f.ArrivalTime = arrival;
            f.PriceOfTheOneSeat = price;
            f.Company = company;
            f.FromName = this.Name;
            f.ToName = to.Name;
            flightList.Add(f);
        }
        public void AddCityToPath(City c)
        {
            Path.Add(c);
            if (c.path != null)
            {
                path = new List<City>();
                
                foreach (City v in c.path)
                {
                    Path.Add(v);
                }
                Path.Add(c);
            }
        }
        public void AddLastCityToMakePath()
        {
            Path.Add(this);
        }

        
       
        [DataMember]
        public String Country
        {
            get
            {
                return country;
            }
            set
            {
                country = value;
            }
        }
      
        public bool Mark
        {
            get
            {
                return _mark;
            }
            set
            {
                _mark = value;
            }
        }

        [DataMember]     
        public String Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
                public override string ToString()
                {

                    return name;
                }

                public int PriceToGetHere
                {
                    get { return priceToGetHere; }
                    set { priceToGetHere = value; }
                }
  
                public IList<City> Path
                {
                    get { return path; }
                    set { path = value; }
                }

                public TimeSpan TimeToGetHere
                {
                    get { return timeToGetHere; }
                    set { timeToGetHere = value; }
                }




    }
}